package com.zpark.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zpark.entity.Member;
import com.zpark.mapper.MemberMapper;
import com.zpark.service.IMemberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Insert;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lx
 * @since 2024-03-18
 */
@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements IMemberService {
@Resource
private MemberMapper mapper;
    @Override
    public Member login(Member member) {
        QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("usname",member.getUsname())
                .eq("psword",member.getPsword());
        Member member1 = mapper.selectOne(queryWrapper);
        return member1;
    }

    @Override
    public int register(Member member) {
        int insert = mapper.insert(member);
        return insert;
    }

    @Override
    public Member selectByUsname(String name) {
        QueryWrapper<Member> wrapper = new QueryWrapper<>();
        wrapper.eq("usname",name);
        Member member1 = mapper.selectOne(wrapper);
        return member1;
    }
}
